package c.d.a.a.i;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import c.d.a.a.b.a;
import c.d.a.a.b.i;
import c.d.a.a.c.l;
import c.d.a.a.j.d;
import c.d.a.a.j.g;
import c.d.a.a.j.h;
import com.github.mikephil.charting.charts.RadarChart;
import java.util.List;
import java.util.Objects;

/* compiled from: YAxisRendererRadarChart */
public class n extends m {
    public RadarChart r;
    public Path s = new Path();

    public n(h hVar, i iVar, RadarChart radarChart) {
        super(hVar, iVar, null);
        this.r = radarChart;
    }

    public void b(float f, float f2) {
        int i = this.b.o;
        double abs = (double) Math.abs(f2 - f);
        a aVar;
        if (i == 0 || abs <= 0.0d || Double.isInfinite(abs)) {
            aVar = this.b;
            aVar.k = new float[0];
            aVar.l = new float[0];
            aVar.m = 0;
            return;
        }
        double d;
        double i2 = (double) g.i(abs / ((double) i));
        Objects.requireNonNull(this.b);
        double i3 = (double) g.i(Math.pow(10.0d, (double) ((int) Math.log10(i2))));
        if (((int) (i2 / i3)) > 5) {
            i2 = Math.floor(i3 * 10.0d);
        }
        Objects.requireNonNull(this.b);
        Objects.requireNonNull(this.b);
        int i4 = (i2 > 0.0d ? 1 : (i2 == 0.0d ? 0 : -1));
        if (i4 == 0) {
            i3 = 0.0d;
        } else {
            i3 = Math.ceil(((double) f) / i2) * i2;
        }
        if (i4 == 0) {
            d = 0.0d;
        } else {
            d = g.h(Math.floor(((double) f2) / i2) * i2);
        }
        if (i4 != 0) {
            i4 = 0;
            for (double d2 = i3; d2 <= d; d2 += i2) {
                i4++;
            }
        } else {
            i4 = 0;
        }
        i4++;
        aVar = this.b;
        aVar.m = i4;
        if (aVar.k.length < i4) {
            aVar.k = new float[i4];
        }
        for (int i5 = 0; i5 < i4; i5++) {
            if (i3 == 0.0d) {
                i3 = 0.0d;
            }
            this.b.k[i5] = (float) i3;
            i3 += i2;
        }
        if (i2 < 1.0d) {
            this.b.n = (int) Math.ceil(-Math.log10(i2));
        } else {
            this.b.n = 0;
        }
        aVar = this.b;
        float[] fArr = aVar.k;
        float f3 = fArr[0];
        aVar.y = f3;
        f2 = fArr[i4 - 1];
        aVar.x = f2;
        aVar.z = Math.abs(f2 - f3);
    }

    public void g(Canvas canvas) {
        i iVar = this.h;
        if (iVar.a && iVar.s) {
            Paint paint = this.e;
            Objects.requireNonNull(iVar);
            paint.setTypeface(null);
            this.e.setTextSize(this.h.d);
            this.e.setColor(this.h.e);
            d centerOffsets = this.r.getCenterOffsets();
            d b = d.b(0.0f, 0.0f);
            float factor = this.r.getFactor();
            i iVar2 = this.h;
            int i = iVar2.A ^ 1;
            boolean z = iVar2.B;
            int i2 = iVar2.m;
            if (!z) {
                i2--;
            }
            while (i < i2) {
                i iVar3 = this.h;
                g.f(centerOffsets, (iVar3.k[i] - iVar3.y) * factor, this.r.getRotationAngle(), b);
                canvas.drawText(this.h.b(i), b.b + 10.0f, b.c, this.e);
                i++;
            }
            d.d.c(centerOffsets);
            d.d.c(b);
        }
    }

    public void j(Canvas canvas) {
        List list = this.h.t;
        if (list != null) {
            float sliceAngle = this.r.getSliceAngle();
            float factor = this.r.getFactor();
            d centerOffsets = this.r.getCenterOffsets();
            d b = d.b(0.0f, 0.0f);
            for (int i = 0; i < list.size(); i++) {
                if (((c.d.a.a.b.g) list.get(i)).a) {
                    this.g.setColor(0);
                    this.g.setPathEffect(null);
                    this.g.setStrokeWidth(0.0f);
                    float yChartMin = (0.0f - this.r.getYChartMin()) * factor;
                    Path path = this.s;
                    path.reset();
                    for (int i2 = 0; i2 < ((c.d.a.a.f.b.i) ((l) this.r.getData()).g()).i0(); i2++) {
                        g.f(centerOffsets, yChartMin, this.r.getRotationAngle() + (((float) i2) * sliceAngle), b);
                        if (i2 == 0) {
                            path.moveTo(b.b, b.c);
                        } else {
                            path.lineTo(b.b, b.c);
                        }
                    }
                    path.close();
                    canvas.drawPath(path, this.g);
                }
            }
            d.d.c(centerOffsets);
            d.d.c(b);
        }
    }
}
